<?php
namespace TennisTournament\Service;

use TennisTournament\Model\Group;
use TennisTournament\Model\Match;

interface MatchService extends GenericService {

    const PLAYERS_IN_MATCH = 2;

    /**
     * Fetch all matches based on their state of tournament
     * @param $stageOfTournament string from {@link StageOfTournamentEnum}
     * @throws LogicException if $stageOfTournament is not one from {@link StageOfTournamentEnum}
     * @return array from all matches or null if doesn't exist such matches
     */
    public function fetchAllWithStageOfTournament($stageOfTournament);

    /**
     * Encode a Match object into a JSON object
     * @param Match $match
     * @return string
     */
    public function toJSON(Match $match);

    /**
     * Create all matches which will be played for specific Group
     * @param Group $group
     * @return void
     */
    public function createMatchesForSpecificGroup(Group $group);

    /**
     * Update Match entity
     * @param Match $match
     * @return void
     */
    public function update(Match $match);

    /**
     * Fetch all matches played in specific Groups
     * @param Group $group
     * @return array | null
     */
    public function getAllMatchesBy(Group $group);

    /**
     * Retrieve all Matches who are played in the current date
     * @param \DateTime $date
     * @return array
     */
    public function getAllMatchesByDate(\DateTime $date);

    /**
     * Check whether all matches in specific stage of tournament are played yet or not.
     * @param $stageOfTournament string
     * @return boolean
     */
    public function isPlayedAllMatchesInStageOfTournament($stageOfTournament);

    /**
     * Create Matches for next Tournament stage.
     * If we should create Matches from Group stage to the next
     * Tournament stage, we receive collection from players from which
     * which will be created new matches.
     * @param $currentStageOfTournament string
     * @return void
     */
    public function createMatchesForNextTournamentStage($currentStageOfTournament);
}